php normalize whitespace characters

34

<?php

function normalizeWhitespaceCharacters( $string )
{
    $stepOne = htmlentities($string);
    $stepTwo = trim(preg_replace('/( )+|\s\K\s+/','', $stepOne));
    $final = html_entity_decode($stepTwo);
    return $final;
}

Comments

Submit
0 Comments